package com.example.administrator.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class Main2Activity extends AppCompatActivity {

    private LinearLayout linearLayou;
    private View button;
    private View button1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
        initData();
        initEvent();
    }

    //第一步创建试图
    private void initView() {
        linearLayou = (LinearLayout) findViewById(R.id.LinearLayout);
        ;
        button = findViewById(R.id.button);
    }

    //第二步 获取数据
    private void initData() {

    }

    //第三步 事件监听
    private void initEvent() {
 button.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
         linearLayou.setBackgroundColor(getResources().getColor(R.color.colorAccent));
     }
 });
    }


}

